//根据"男生"、"女生"获取书籍

export async function getBooks_by_gender(type, proxy) {
  
    // URL 编码关键词
    const gender = encodeURIComponent(type);
    console.log(gender);

    try {
      const response = await proxy.$http.get(`/api/book/type/${gender}`);
      // 检查响应的实际结构
      if (response.data && response.data.data && response.data.data.book) {
        const books = response.data.data.book;
        return books.slice(0, 7);
      }
      else
        console.error('男频女频，响应结构不符合预期:', response);

    } catch (error) {
      console.error(`Error fetching ${type} books:`, error);
      return [];
    }

}
